home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / c / ObjectiveGT1_0.lha / Examples / Manx / demoPosition.c < prev    next >
C/C++ Source or Header  |  1992-10-21  |  32KB  |  947 lines

  1. /*
  2. ** $Filename: demoPosition.c $
  3. ** $Release : 1.0            $
  4. ** $Revision: 1.047          $
  5. ** $Date    : 21/10/92       $
  6. **
  7. **
  8. ** (C) Copyright 1992 Davide Massarenti
  9. **              All Rights Reserved
  10. **
  11. ** MANX 5.2: cc -ps -wdrunpo -so <name>.c
  12. **           ln -o <name> <name>.o -lOGTglue -lc16
  13. **
  14. */
  15.  
  16. #include <OGT/ObjectiveGadTools.h>
  17.  
  18. #define ARGS_TEMPLATE "FONT/K,SIZE/N"
  19. #define ARGS_FONT       (0)
  20. #define ARGS_SIZE       (1)
  21. #define ARGS_NUMOF      (2)
  22.  
  23. static LONG args[ ARGS_NUMOF ];
  24.  
  25.  
  26. #define ID_X_POS        1
  27. #define ID_X_HANDLE     2
  28. #define ID_X_MODE       3
  29. #define ID_X_VALUE      4
  30.  
  31. #define ID_Y_POS        5
  32. #define ID_Y_HANDLE     6
  33. #define ID_Y_MODE       7
  34. #define ID_Y_VALUE      8
  35.  
  36. #define ID_W_DIM        9
  37. #define ID_W_MODE       10
  38. #define ID_W_VALUE      11
  39. #define ID_W_POS        12
  40.  
  41. #define ID_H_DIM        13
  42. #define ID_H_MODE       14
  43. #define ID_H_VALUE      15
  44. #define ID_H_POS        16
  45.  
  46. #define ID_REFERENCE    17
  47. #define ID_DEMO         18
  48.  
  49.  
  50. static char Class_Group [] =  GROUP_OGT_CLASS;
  51. static char Class_Button[] = BUTTON_OGT_CLASS;
  52. static char Class_String[] = STRING_OGT_CLASS;
  53.  
  54.  
  55. struct TextAttr          MyAttr = { NULL, 8 };
  56. struct TextFont         *MyFont;
  57.  
  58. APTR                     VInfo;
  59. struct Window           *Win;
  60. Object                 **Gads;
  61. struct RDArgs           *Ra;
  62.  
  63. struct TagItem WindowDescTags[] =
  64. {
  65.    { OVI_GimmeZeroZero    , TRUE                                    },
  66.    { OVI_AdaptWidthToFont , TRUE                                    },
  67.    { OVI_AdaptHeightToFont, TRUE                                    },
  68.  
  69.    { OGT_ScaleLeft        , OGT_FontRelative                        },
  70.    { OGT_ScaleTop         , OGT_FontRelative                        },
  71.    { OGT_ScaleWidth       , OGT_FontRelative                        },
  72.    { OGT_ScaleHeight      , OGT_FontRelative                        },
  73.    { OGT_DomainXscale     , ~0                                      },
  74.    { OGT_DomainYscale     , ~0                                      },
  75.  
  76.    { WA_Activate          , TRUE                                    },
  77.    { WA_SmartRefresh      , TRUE                                    },
  78.    { WA_NoCareRefresh     , TRUE                                    },
  79.    { WA_DepthGadget       , TRUE                                    },
  80.    { WA_SizeGadget        , TRUE                                    },
  81.    { WA_DragBar           , TRUE                                    },
  82.    { WA_Left              , 400                                     },
  83.    { WA_Top               , 150                                     },
  84.    { WA_InnerWidth        , 398                                     },
  85.    { WA_InnerHeight       , 300                                     },
  86.    { WA_MaxWidth          , -1                                      },
  87.    { WA_MaxHeight         , -1                                      },
  88.    { WA_IDCMP             , (IDCMP_CLOSEWINDOW | IDCMP_IDCMPUPDATE) },
  89.    { WA_CloseGadget       , TRUE                                    },
  90.    { WA_Title             , "Demo Dimensions"                       },
  91.  
  92.    { TAG_DONE                                                       },
  93. };
  94.  
  95.  
  96. STRPTR Labels1[] =
  97. {
  98.    "Left"  ,
  99.    "Center",
  100.    "Right" ,
  101.    NULL    ,
  102. };
  103.  
  104. STRPTR Labels2[] =
  105. {
  106.    "Top"   ,
  107.    "Center",
  108.    "Bottom",
  109.    NULL    ,
  110. };
  111.  
  112. STRPTR Labels3[] =
  113. {
  114.    "Free"     ,
  115.    "Align"    ,
  116.    "Center"   ,
  117.    "In Border",
  118.    NULL       ,
  119. };
  120.  
  121. STRPTR Labels4[] =
  122. {
  123.    "Fixed"   ,
  124.    "Relative",
  125.    "As Coord",
  126.    NULL      ,
  127. };
  128.  
  129.  
  130. struct TagItem Object1_0Desc[] = /* GROUP_OGT_CLASS */
  131. {
  132.    { GA_Left          , 2                     },
  133.    { GA_Top           , 12                    },
  134.    { GA_Width         , 394                   },
  135.    { GA_Height        , 30                    },
  136.  
  137.    { GA_Text          , "Horizontal Position" },
  138.    { OGT_TextPlacement, OGT_Text_ABOVE        },
  139.    { OGT_DrawFrame    , TRUE                  },
  140.  
  141.    { TAG_DONE                                 },
  142. };
  143.  
  144. struct TagItem Object1_1Desc[] = /* BUTTON_OGT_CLASS */
  145. {
  146.    { GA_ID            , ID_X_POS       },
  147.    { GA_RelVerify     , TRUE           },
  148.  
  149.    { GA_Left          , 4              },
  150.    { GA_Top           , 12             },
  151.    { GA_Width         , 80             },
  152.    { GA_Height        , 16             },
  153.  
  154.    { GA_Text          , "Pos"          },
  155.    { OGT_TextPlacement, OGT_Text_ABOVE },
  156.    { OGTBU_Labels     , Labels1        },
  157.    { OGTBU_ActiveLabel, 0              },
  158.  
  159.    { TAG_DONE                          },
  160. };
  161.  
  162. struct TagItem Object1_2Desc[] = /* BUTTON_OGT_CLASS */
  163. {
  164.    { GA_ID              , ID_X_HANDLE        },
  165.    { GA_RelVerify       , TRUE               },
  166.  
  167.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  168.    { GA_Left            , 8                  },
  169.    { GA_Width           , 94                 },
  170.    { GA_Height          , 16                 },
  171.  
  172.    { GA_Text            , "Handle by"        },
  173.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  174.    { OGTBU_Labels       , Labels1            },
  175.    { OGTBU_ActiveLabel  , 0                  },
  176.  
  177.    { TAG_DONE                                },
  178. };
  179.  
  180. struct TagItem Object1_3Desc[] = /* BUTTON_OGT_CLASS */
  181. {
  182.    { GA_ID              , ID_X_MODE          },
  183.    { GA_RelVerify       , TRUE               },
  184.  
  185.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  186.    { GA_Left            , 8                  },
  187.    { GA_Width           , 94                 },
  188.    { GA_Height          , 16                 },
  189.  
  190.    { GA_Text            , "Mode"             },
  191.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  192.    { OGTBU_Labels       , Labels3            },
  193.    { OGTBU_ActiveLabel  , 0                  },
  194.  
  195.    { TAG_DONE                                },
  196. };
  197.  
  198. struct TagItem Object1_4Desc[] = /* STRING_OGT_CLASS */
  199. {
  200.    { GA_ID              , ID_X_VALUE         },
  201.    { GA_RelVerify       , TRUE               },
  202.  
  203.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  204.    { GA_Left            , 8                  },
  205.    { GA_Width           , 94                 },
  206.    { GA_Height          , 16                 },
  207.  
  208.    { GA_Text            , "Value"            },
  209.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  210.  
  211.    { STRINGA_MaxChars   , 32                 },
  212.    { STRINGA_LongVal    , 2                  },
  213.    { GA_TabCycle        , TRUE               },
  214.  
  215.    { TAG_DONE                                },
  216. };
  217.  
  218.  
  219. struct TagItem Object2_0Desc[] = /* GROUP_OGT_CLASS */
  220. {
  221.    { GA_Left          , 2                   },
  222.    { GA_Top           , 54                  },
  223.    { GA_Width         , 394                 },
  224.    { GA_Height        , 30                  },
  225.  
  226.    { GA_Text          , "Vertical Position" },
  227.    { OGT_TextPlacement, OGT_Text_ABOVE      },
  228.    { OGT_DrawFrame    , TRUE                },
  229.  
  230.    { TAG_DONE                               },
  231. };
  232.  
  233. struct TagItem Object2_1Desc[] = /* BUTTON_OGT_CLASS */
  234. {
  235.    { GA_ID            , ID_Y_POS       },
  236.    { GA_RelVerify     , TRUE           },
  237.  
  238.    { GA_Left          , 4              },
  239.    { GA_Top           , 12             },
  240.    { GA_Width         , 80             },
  241.    { GA_Height        , 16             },
  242.  
  243.    { GA_Text          , "Pos"          },
  244.    { OGT_TextPlacement, OGT_Text_ABOVE },
  245.    { OGTBU_Labels     , Labels2        },
  246.    { OGTBU_ActiveLabel, 0              },
  247.  
  248.    { TAG_DONE                          },
  249. };
  250.  
  251. struct TagItem Object2_2Desc[] = /* BUTTON_OGT_CLASS */
  252. {
  253.    { GA_ID              , ID_Y_HANDLE        },
  254.    { GA_RelVerify       , TRUE               },
  255.  
  256.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  257.    { GA_Left            , 8                  },
  258.    { GA_Width           , 94                 },
  259.    { GA_Height          , 16                 },
  260.  
  261.    { GA_Text            , "Handle by"        },
  262.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  263.    { OGTBU_Labels       , Labels2            },
  264.    { OGTBU_ActiveLabel  , 0                  },
  265.  
  266.    { TAG_DONE                                },
  267. };
  268.  
  269. struct TagItem Object2_3Desc[] = /* BUTTON_OGT_CLASS */
  270. {
  271.    { GA_ID              , ID_Y_MODE          },
  272.    { GA_RelVerify       , TRUE               },
  273.  
  274.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  275.    { GA_Left            , 8                  },
  276.    { GA_Width           , 94                 },
  277.    { GA_Height          , 16                 },
  278.  
  279.    { GA_Text            , "Mode"             },
  280.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  281.    { OGTBU_Labels       , Labels3            },
  282.    { OGTBU_ActiveLabel  , 0                  },
  283.  
  284.    { TAG_DONE                                },
  285. };
  286.  
  287. struct TagItem Object2_4Desc[] = /* STRING_OGT_CLASS */
  288. {
  289.    { GA_ID              , ID_Y_VALUE         },
  290.    { GA_RelVerify       , TRUE               },
  291.  
  292.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  293.    { GA_Left            , 8                  },
  294.    { GA_Width           , 94                 },
  295.    { GA_Height          , 16                 },
  296.  
  297.    { GA_Text            , "Value"            },
  298.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  299.  
  300.    { STRINGA_MaxChars   , 32                 },
  301.    { STRINGA_LongVal    , 1                  },
  302.    { GA_TabCycle        , TRUE               },
  303.  
  304.    { TAG_DONE                                },
  305. };
  306.  
  307.  
  308. struct TagItem Object3_0Desc[] = /* GROUP_OGT_CLASS */
  309. {
  310.    { GA_Left          , 2                      },
  311.    { GA_Top           , 96                     },
  312.    { GA_Width         , 394                    },
  313.    { GA_Height        , 30                     },
  314.  
  315.    { GA_Text          , "Horizontal Dimension" },
  316.    { OGT_TextPlacement, OGT_Text_ABOVE         },
  317.    { OGT_DrawFrame    , TRUE                   },
  318.  
  319.    { TAG_DONE                                  },
  320. };
  321.  
  322. struct TagItem Object3_1Desc[] = /* BUTTON_OGT_CLASS */
  323. {
  324.    { GA_ID            , ID_W_DIM       },
  325.    { GA_RelVerify     , TRUE           },
  326.  
  327.    { GA_Left          , 4              },
  328.    { GA_Top           , 12             },
  329.    { GA_Width         , 80             },
  330.    { GA_Height        , 16             },
  331.  
  332.    { GA_Text          , "Dim"          },
  333.    { OGT_TextPlacement, OGT_Text_ABOVE },
  334.    { OGTBU_Labels     , Labels4        },
  335.    { OGTBU_ActiveLabel, 0              },
  336.  
  337.    { TAG_DONE                          },
  338. };
  339.  
  340. struct TagItem Object3_2Desc[] = /* BUTTON_OGT_CLASS */
  341. {
  342.    { GA_ID              , ID_W_MODE          },
  343.    { GA_RelVerify       , TRUE               },
  344.  
  345.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  346.    { GA_Left            , 8                  },
  347.    { GA_Width           , 94                 },
  348.    { GA_Height          , 16                 },
  349.  
  350.    { GA_Text            , "Mode"             },
  351.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  352.    { OGTBU_Labels       , Labels3            },
  353.    { OGTBU_ActiveLabel  , 0                  },
  354.  
  355.    { TAG_DONE                                },
  356. };
  357.  
  358. struct TagItem Object3_3Desc[] = /* STRING_OGT_CLASS */
  359. {
  360.    { GA_ID              , ID_W_VALUE         },
  361.    { GA_RelVerify       , TRUE               },
  362.  
  363.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  364.    { GA_Left            , 8                  },
  365.    { GA_Width           , 94                 },
  366.    { GA_Height          , 16                 },
  367.  
  368.    { GA_Text            , "Value"            },
  369.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  370.  
  371.    { STRINGA_MaxChars   , 32                 },
  372.    { STRINGA_LongVal    , 40                 },
  373.    { GA_TabCycle        , TRUE               },
  374.  
  375.    { TAG_DONE                                },
  376. };
  377.  
  378. struct TagItem Object3_4Desc[] = /* BUTTON_OGT_CLASS */
  379. {
  380.    { GA_ID              , ID_W_POS           },
  381.    { GA_RelVerify       , TRUE               },
  382.    { GA_Disabled        , TRUE               },
  383.  
  384.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  385.    { GA_Left            , 8                  },
  386.    { GA_Width           , 80                 },
  387.    { GA_Height          , 16                 },
  388.  
  389.    { GA_Text            , "Pos"              },
  390.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  391.    { OGTBU_Labels       , Labels1            },
  392.    { OGTBU_ActiveLabel  , 0                  },
  393.  
  394.    { TAG_DONE                                },
  395. };
  396.  
  397.  
  398. struct TagItem Object4_0Desc[] = /* GROUP_OGT_CLASS */
  399. {
  400.    { GA_Left          , 2                      },
  401.    { GA_Top           , 138                    },
  402.    { GA_Width         , 394                    },
  403.    { GA_Height        , 30                     },
  404.  
  405.    { GA_Text          , "Vertical Dimension"   },
  406.    { OGT_TextPlacement, OGT_Text_ABOVE         },
  407.    { OGT_DrawFrame    , TRUE                   },
  408.  
  409.    { TAG_DONE                                  },
  410. };
  411.  
  412. struct TagItem Object4_1Desc[] = /* BUTTON_OGT_CLASS */
  413. {
  414.    { GA_ID            , ID_H_DIM       },
  415.    { GA_RelVerify     , TRUE           },
  416.  
  417.    { GA_Left          , 4              },
  418.    { GA_Top           , 12             },
  419.    { GA_Width         , 80             },
  420.    { GA_Height        , 16             },
  421.  
  422.    { GA_Text          , "Dim"          },
  423.    { OGT_TextPlacement, OGT_Text_ABOVE },
  424.    { OGTBU_Labels     , Labels4        },
  425.    { OGTBU_ActiveLabel, 0              },
  426.  
  427.    { TAG_DONE                          },
  428. };
  429.  
  430. struct TagItem Object4_2Desc[] = /* BUTTON_OGT_CLASS */
  431. {
  432.    { GA_ID              , ID_H_MODE          },
  433.    { GA_RelVerify       , TRUE               },
  434.  
  435.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  436.    { GA_Left            , 8                  },
  437.    { GA_Width           , 94                 },
  438.    { GA_Height          , 16                 },
  439.  
  440.    { GA_Text            , "Mode"             },
  441.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  442.    { OGTBU_Labels       , Labels3            },
  443.    { OGTBU_ActiveLabel  , 0                  },
  444.  
  445.    { TAG_DONE                                },
  446. };
  447.  
  448. struct TagItem Object4_3Desc[] = /* STRING_OGT_CLASS */
  449. {
  450.    { GA_ID              , ID_H_VALUE         },
  451.    { GA_RelVerify       , TRUE               },
  452.  
  453.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  454.    { GA_Left            , 8                  },
  455.    { GA_Width           , 94                 },
  456.    { GA_Height          , 16                 },
  457.  
  458.    { GA_Text            , "Value"            },
  459.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  460.  
  461.    { STRINGA_MaxChars   , 32                 },
  462.    { STRINGA_LongVal    , 12                 },
  463.    { GA_TabCycle        , TRUE               },
  464.  
  465.    { TAG_DONE                                },
  466. };
  467.  
  468. struct TagItem Object4_4Desc[] = /* BUTTON_OGT_CLASS */
  469. {
  470.    { GA_ID              , ID_H_POS           },
  471.    { GA_RelVerify       , TRUE               },
  472.    { GA_Disabled        , TRUE               },
  473.  
  474.    { OGT_SetPosReference, (OGT_X_Mode_Align) },
  475.    { GA_Left            , 8                  },
  476.    { GA_Width           , 80                 },
  477.    { GA_Height          , 16                 },
  478.  
  479.    { GA_Text            , "Pos"              },
  480.    { OGT_TextPlacement  , OGT_Text_ABOVE     },
  481.    { OGTBU_Labels       , Labels2            },
  482.    { OGTBU_ActiveLabel  , 0                  },
  483.  
  484.    { TAG_DONE                                },
  485. };
  486.  
  487.  
  488. struct TagItem Object5_0Desc[] = /* GROUP_OGT_CLASS */
  489. {
  490.    { GA_Top       , 180  },
  491.    { GA_RelWidth  , -40  },
  492.    { GA_RelHeight , -190 },
  493.  
  494.    { OGT_DrawFrame, TRUE },
  495.  
  496.    { TAG_DONE            },
  497. };
  498.  
  499. struct TagItem Object5_1Desc[] = /* BUTTON_OGT_CLASS */
  500. {
  501.    { GA_ID          , ID_REFERENCE },
  502.    { GA_Immediate   , TRUE         },
  503.    { GA_FollowMouse , TRUE         },
  504.  
  505.    { OGT_ScaleLeft  , OGT_Fixed    },
  506.    { OGT_ScaleTop   , OGT_Fixed    },
  507.    { GA_Left        , 100          },
  508.    { GA_Top         , 40           },
  509.    { GA_Width       , 80           },
  510.    { GA_Height      , 12           },
  511.  
  512.    { GA_Text        , "Reference"  },
  513.  
  514.    { TAG_DONE                      },
  515. };
  516.  
  517. struct TagItem Object5_2Desc[] = /* BUTTON_OGT_CLASS */
  518. {
  519.    { GA_ID     , ID_DEMO     },
  520.    { GA_Left   , 2           },
  521.    { GA_Top    , 1           },
  522.    { GA_Width  , 40          },
  523.    { GA_Height , 12          },
  524.  
  525.    { GA_Text   , "Demo"      },
  526.  
  527.    { TAG_DONE                },
  528. };
  529.  
  530. struct OGT_ObjectSettings ListOfObjects[] =
  531. {
  532.    { Class_Group , Object1_0Desc, NULL , OGT_NOOBJECT, OGT_NOOBJECT },
  533.    { Class_Button, Object1_1Desc, NULL , 0           , OGT_NOOBJECT },
  534.    { Class_Button, Object1_2Desc, NULL , 0           , OGT_NOOBJECT },
  535.    { Class_Button, Object1_3Desc, NULL , 0           , OGT_NOOBJECT },
  536.    { Class_String, Object1_4Desc, NULL , 0           , OGT_NOOBJECT },
  537.  
  538.    { Class_Group , Object2_0Desc, NULL , OGT_NOOBJECT, OGT_NOOBJECT },
  539.    { Class_Button, Object2_1Desc, NULL , 5           , OGT_NOOBJECT },
  540.    { Class_Button, Object2_2Desc, NULL , 5           , OGT_NOOBJECT },
  541.    { Class_Button, Object2_3Desc, NULL , 5           , OGT_NOOBJECT },
  542.    { Class_String, Object2_4Desc, NULL , 5           , OGT_NOOBJECT },
  543.  
  544.    { Class_Group , Object3_0Desc, NULL , OGT_NOOBJECT, OGT_NOOBJECT },
  545.    { Class_Button, Object3_1Desc, NULL , 10          , OGT_NOOBJECT },
  546.    { Class_Button, Object3_2Desc, NULL , 10          , OGT_NOOBJECT },
  547.    { Class_String, Object3_3Desc, NULL , 10          , OGT_NOOBJECT },
  548.    { Class_Button, Object3_4Desc, NULL , 10          , OGT_NOOBJECT },
  549.  
  550.    { Class_Group , Object4_0Desc, NULL , OGT_NOOBJECT, OGT_NOOBJECT },
  551.    { Class_Button, Object4_1Desc, NULL , 15          , OGT_NOOBJECT },
  552.    { Class_Button, Object4_2Desc, NULL , 15          , OGT_NOOBJECT },
  553.    { Class_String, Object4_3Desc, NULL , 15          , OGT_NOOBJECT },
  554.    { Class_Button, Object4_4Desc, NULL , 15          , OGT_NOOBJECT },
  555.  
  556.    { Class_Group , Object5_0Desc, NULL , OGT_NOOBJECT, OGT_NOOBJECT },
  557.    { Class_Button, Object5_1Desc, NULL , 20          , OGT_NOOBJECT },
  558.    { Class_Button, Object5_2Desc, NULL , 20          , OGT_NOOBJECT },
  559.    { NULL                                                           },
  560. };
  561.  
  562. struct OGT_ObjectLink ListOfLinks[] =
  563. {
  564.    { OGT_NOOBJECT },
  565. };
  566.  
  567. static void cleanup           ( char *str );
  568. static void goHandleWindowWait( void      );
  569. static BOOL goHandleWindow    ( void      );
  570.  
  571.  
  572. void main( void )
  573. {
  574.    if(!OpenOGT()) cleanup( "no objectivegadtools library\n" );
  575.  
  576.    if(!(Ra = ReadArgs( ARGS_TEMPLATE, args, NULL ))) cleanup( "can't parse args\n" );
  577.  
  578.    if(args[ ARGS_FONT ]) MyAttr.ta_Name  =  (void  *)args[ ARGS_FONT ];
  579.    if(args[ ARGS_SIZE ]) MyAttr.ta_YSize = *(ULONG *)args[ ARGS_SIZE ];
  580.  
  581.    if(MyAttr.ta_Name)
  582.    {
  583.       if(!(MyFont = OpenDiskFont( &MyAttr ))) cleanup( "can't open font!!\n" );
  584.    }
  585.  
  586.    VInfo = OGT_GetVisualInfo( NULL, OGT_TextFont, (ULONG)MyFont         ,
  587.                                     TAG_MORE    , (ULONG)WindowDescTags );
  588.  
  589.    if(VInfo == NULL) cleanup( "can't open my window.\n" );
  590.  
  591.    if(!OGT_BuildObjects( VInfo, ListOfObjects, ListOfLinks, &Gads )) cleanup( "can't create objects" );
  592.  
  593.    Win = OGT_GetWindowPtr( VInfo );
  594.  
  595.    goHandleWindowWait();
  596.  
  597.    cleanup( "all done" );
  598. }
  599.  
  600. static void cleanup( char *str )
  601. {
  602.    if(str) Printf( "%s\n", str );
  603.  
  604.    if(Ra    ) FreeArgs          ( Ra     );
  605.    if(Gads  ) FreeVec           ( Gads   );
  606.    if(VInfo ) OGT_FreeVisualInfo( VInfo  );
  607.    if(MyFont) CloseFont         ( MyFont );
  608.  
  609.    CloseOGT();
  610.  
  611.    Exit( 0 );
  612. }
  613.  
  614. static void goHandleWindowWait( void )
  615. {
  616.    BOOL keeprunning = TRUE;
  617.  
  618.    while(keeprunning)
  619.    {
  620.       Wait( 1L << Win->UserPort->mp_SigBit );
  621.  
  622.       keeprunning = goHandleWindow();
  623.    }
  624. }
  625.  
  626. static BOOL goHandleWindow( void )
  627. {
  628.    BOOL                 keeprunning = TRUE;
  629.  
  630.    struct IntuiMessage *imsg;
  631.  
  632.    while(keeprunning && (imsg = OGT_GetMsg( VInfo )))
  633.    {
  634.       switch(imsg->Class)
  635.       {
  636.          case IDCMP_CLOSEWINDOW:
  637.             keeprunning = FALSE;
  638.             break;
  639.  
  640.          case IDCMP_IDCMPUPDATE:
  641.             {
  642.                struct dump_data
  643.                {
  644.                   ULONG pos;
  645.                   ULONG handle;
  646.                   ULONG dim;
  647.  
  648.                   LONG  left;
  649.                   LONG  top;
  650.                   LONG  width;
  651.                   LONG  height;
  652.                };
  653.  
  654.                struct TagItem *tags = imsg->IAddress;
  655.  
  656.                if(GetTagData( OGT_AskedHelp, FALSE, tags ))
  657.                {
  658.                   STRPTR node = NULL;
  659.  
  660.                   /* Do Help */
  661.                   switch(GetTagData( OGT_ID, -1, tags ))
  662.                   {
  663.                      case ID_X_POS     :
  664.                      case ID_Y_POS     : node = "pos_pos"         ; break;
  665.                      case ID_X_HANDLE  :
  666.                      case ID_Y_HANDLE  : node = "pos_handle"      ; break;
  667.                      case ID_X_MODE    :
  668.                      case ID_Y_MODE    : node = "pos_mode"        ; break;
  669.                      case ID_X_VALUE   :
  670.                      case ID_Y_VALUE   : node = "pos_value"       ; break;
  671.  
  672.                      case ID_W_DIM     :
  673.                      case ID_H_DIM     : node = "dim_dim"         ; break;
  674.                      case ID_W_MODE    :
  675.                      case ID_H_MODE    : node = "dim_mode"        ; break;
  676.                      case ID_W_VALUE   :
  677.                      case ID_H_VALUE   : node = "dim_value"       ; break;
  678.                      case ID_W_POS     :
  679.                      case ID_H_POS     : node = "dim_dim"         ; break;
  680.  
  681.  
  682.                      case ID_REFERENCE : node = "gadget_reference"; break;
  683.                      case ID_DEMO      : node = "gadget_demo"     ; break;
  684.                   }
  685.  
  686.                   if(node)
  687.                   {
  688.                      char buffer[ 512 ];
  689.  
  690.                      strcpy( buffer, "AmigaGuide demoPosition.guide doc " );
  691.                      strcat( buffer, node                                 );
  692.  
  693.                      SystemTags( buffer, TAG_DONE );
  694.                   }
  695.                }
  696.                else
  697.                {
  698.                   ULONG           data1 = GetTagData( OGTBU_ActiveLabel, -1, tags );
  699.                   ULONG           data2 = GetTagData( STRINGA_LongVal  ,  0, tags );
  700.  
  701.                   struct dump_data new;
  702.                   struct dump_data old;
  703.  
  704.                   GetAttr( OGT_SetPosReference, Gads[ 22 ], &old.pos    );
  705.                   GetAttr( OGT_SetPosHandle   , Gads[ 22 ], &old.handle );
  706.                   GetAttr( OGT_SetDimReference, Gads[ 22 ], &old.dim    );
  707.                   GetAttr( GA_Left            , Gads[ 22 ], &old.left   );
  708.                   GetAttr( GA_Top             , Gads[ 22 ], &old.top    );
  709.                   GetAttr( GA_Width           , Gads[ 22 ], &old.width  );
  710.                   GetAttr( GA_Height          , Gads[ 22 ], &old.height );
  711.  
  712.                   new = old;
  713.  
  714.                   switch( GetTagData( OGT_ID, -1, tags ) )
  715.                   {
  716.                      case ID_X_POS:
  717.                         new.pos &= ~OGT_X_Pos_Mask;
  718.  
  719.                         switch(data1)
  720.                         {
  721.                            case 0: new.pos |= OGT_X_Left  ; break;
  722.                            case 1: new.pos |= OGT_X_Center; break;
  723.                            case 2: new.pos |= OGT_X_Right ; break;
  724.                         }
  725.                         break;
  726.  
  727.                      case ID_X_HANDLE:
  728.                         new.handle &= ~OGT_X_Pos_Mask;
  729.  
  730.                         switch(data1)
  731.                         {
  732.                            case 0: new.handle |= OGT_X_Left  ; break;
  733.                            case 1: new.handle |= OGT_X_Center; break;
  734.                            case 2: new.handle |= OGT_X_Right ; break;
  735.                         }
  736.                         break;
  737.  
  738.                      case ID_X_MODE:
  739.                         new.pos &= ~OGT_X_Mode_Mask;
  740.  
  741.                         switch(data1)
  742.                         {
  743.                            case 0: new.pos |= OGT_X_Mode_Free     ; break;
  744.                            case 1: new.pos |= OGT_X_Mode_Align    ; break;
  745.                            case 2: new.pos |= OGT_X_Mode_Center   ; break;
  746.                            case 3: new.pos |= OGT_X_Mode_In_Border; break;
  747.                         }
  748.                         break;
  749.  
  750.                      case ID_X_VALUE:
  751.                         new.left = data2;
  752.                         break;
  753.  
  754.  
  755.                      case ID_Y_POS:
  756.                         new.pos &= ~OGT_Y_Pos_Mask;
  757.  
  758.                         switch(data1)
  759.                         {
  760.                            case 0: new.pos |= OGT_Y_Top   ; break;
  761.                            case 1: new.pos |= OGT_Y_Center; break;
  762.                            case 2: new.pos |= OGT_Y_Bottom; break;
  763.                         }
  764.                         break;
  765.  
  766.                      case ID_Y_HANDLE:
  767.                         new.handle &= ~OGT_Y_Pos_Mask;
  768.  
  769.                         switch(data1)
  770.                         {
  771.                            case 0: new.handle |= OGT_Y_Top   ; break;
  772.                            case 1: new.handle |= OGT_Y_Center; break;
  773.                            case 2: new.handle |= OGT_Y_Bottom; break;
  774.                         }
  775.                         break;
  776.  
  777.                      case ID_Y_MODE:
  778.                         new.pos &= ~OGT_Y_Mode_Mask;
  779.  
  780.                         switch(data1)
  781.                         {
  782.                            case 0: new.pos |= OGT_Y_Mode_Free     ; break;
  783.                            case 1: new.pos |= OGT_Y_Mode_Align    ; break;
  784.                            case 2: new.pos |= OGT_Y_Mode_Center   ; break;
  785.                            case 3: new.pos |= OGT_Y_Mode_In_Border; break;
  786.                         }
  787.                         break;
  788.  
  789.                      case ID_Y_VALUE:
  790.                         new.top  = data2;
  791.                         break;
  792.  
  793.  
  794.  
  795.                      case ID_W_DIM:
  796.                         if(((new.dim & OGT_X_Dim_Mask) == OGT_X_Dim_AsCoord) ^ (data1 == 2))
  797.                         {
  798.                            SetGadgetAttrs( Gads[ 14 ], Win, NULL, GA_Disabled, (ULONG)((data1 == 2) ? FALSE : TRUE),
  799.                                                                   TAG_DONE                                         );
  800.                         }
  801.  
  802.                         new.dim &= ~OGT_X_Dim_Mask;
  803.  
  804.                         switch(data1)
  805.                         {
  806.                            case 0: new.dim |= OGT_X_Dim_Fixed   ; break;
  807.                            case 1: new.dim |= OGT_X_Dim_Relative; break;
  808.                            case 2: new.dim |= OGT_X_Dim_AsCoord ; break;
  809.                         }
  810.                         break;
  811.  
  812.                      case ID_W_MODE:
  813.                         new.dim &= ~OGT_X_Mode_Mask;
  814.  
  815.                         switch(data1)
  816.                         {
  817.                            case 0: new.dim |= OGT_X_Mode_Free     ; break;
  818.                            case 1: new.dim |= OGT_X_Mode_Align    ; break;
  819.                            case 2: new.dim |= OGT_X_Mode_Center   ; break;
  820.                            case 3: new.dim |= OGT_X_Mode_In_Border; break;
  821.                         }
  822.                         break;
  823.  
  824.                      case ID_W_VALUE:
  825.                         new.width  = data2;
  826.                         break;
  827.  
  828.                      case ID_W_POS:
  829.                         new.dim &= ~OGT_X_Pos_Mask;
  830.  
  831.                         switch(data1)
  832.                         {
  833.                            case 0: new.dim |= OGT_X_Left  ; break;
  834.                            case 1: new.dim |= OGT_X_Center; break;
  835.                            case 2: new.dim |= OGT_X_Right ; break;
  836.                         }
  837.                         break;
  838.  
  839.  
  840.                      case ID_H_DIM:
  841.                         if(((new.dim & OGT_Y_Dim_Mask) == OGT_Y_Dim_AsCoord) ^ (data1 == 2))
  842.                         {
  843.                            SetGadgetAttrs( Gads[ 19 ], Win, NULL, GA_Disabled, (ULONG)((data1 == 2) ? FALSE : TRUE),
  844.                                                                   TAG_DONE                                         );
  845.                         }
  846.  
  847.                         new.dim &= ~OGT_Y_Dim_Mask;
  848.  
  849.                         switch(data1)
  850.                         {
  851.                            case 0: new.dim |= OGT_Y_Dim_Fixed   ; break;
  852.                            case 1: new.dim |= OGT_Y_Dim_Relative; break;
  853.                            case 2: new.dim |= OGT_Y_Dim_AsCoord ; break;
  854.                         }
  855.                         break;
  856.  
  857.                      case ID_H_MODE:
  858.                         new.dim &= ~OGT_Y_Mode_Mask;
  859.  
  860.                         switch(data1)
  861.                         {
  862.                            case 0: new.dim |= OGT_Y_Mode_Free     ; break;
  863.                            case 1: new.dim |= OGT_Y_Mode_Align    ; break;
  864.                            case 2: new.dim |= OGT_Y_Mode_Center   ; break;
  865.                            case 3: new.dim |= OGT_Y_Mode_In_Border; break;
  866.                         }
  867.                         break;
  868.  
  869.                      case ID_H_VALUE:
  870.                         new.height = data2;
  871.                         break;
  872.  
  873.                      case ID_H_POS:
  874.                         new.dim &= ~OGT_Y_Pos_Mask;
  875.  
  876.                         switch(data1)
  877.                         {
  878.                            case 0: new.dim |= OGT_Y_Top   ; break;
  879.                            case 1: new.dim |= OGT_Y_Center; break;
  880.                            case 2: new.dim |= OGT_Y_Bottom; break;
  881.                         }
  882.                         break;
  883.  
  884.                      case ID_REFERENCE:
  885.                         {
  886.                            static UWORD old_x;
  887.                            static UWORD old_y;
  888.  
  889.                            UWORD x;
  890.                            UWORD y;
  891.  
  892.                            {
  893.                               x = imsg->MouseX;
  894.                               y = imsg->MouseY;
  895.                               x = Win->MouseX;
  896.                               y = Win->MouseY;
  897.                            }
  898.  
  899.                            if(GetTagData( OGT_GadgetDown, FALSE, tags ))
  900.                            {
  901.                               old_x = x;
  902.                               old_y = y;
  903.                            }
  904.                            else if(GetTagData( OGT_GadgetMove, FALSE, tags ))
  905.                            {
  906.                               if(x != old_x || y != old_y)
  907.                               {
  908.                                  ULONG dump;
  909.  
  910.                                  GetAttr( GA_Left, Gads[ 21 ], &dump ); old_x = dump + x - old_x;
  911.                                  GetAttr( GA_Top , Gads[ 21 ], &dump ); old_y = dump + y - old_y;
  912.  
  913.                                  SetGadgetAttrs( Gads[ 21 ], Win, NULL, GA_Left , (ULONG)old_x,
  914.                                                                         GA_Top  , (ULONG)old_y,
  915.                                                                         TAG_DONE              );
  916.  
  917.                                  old_x = x;
  918.                                  old_y = y;
  919.                               }
  920.                            }
  921.                         }
  922.                         break;
  923.                   }
  924.  
  925.                   if(old != new)
  926.                   {
  927.                      SetGadgetAttrs( Gads[ 22 ], Win, NULL, (old.pos    != new.pos   ) ? OGT_SetPosReference : TAG_IGNORE, (ULONG)new.pos   ,
  928.                                                             (old.handle != new.handle) ? OGT_SetPosHandle    : TAG_IGNORE, (ULONG)new.handle,
  929.                                                             (old.dim    != new.dim   ) ? OGT_SetDimReference : TAG_IGNORE, (ULONG)new.dim   ,
  930.                                                             (old.left   != new.left  ) ? GA_Left             : TAG_IGNORE, (ULONG)new.left  ,
  931.                                                             (old.top    != new.top   ) ? GA_Top              : TAG_IGNORE, (ULONG)new.top   ,
  932.                                                             (old.width  != new.width ) ? GA_Width            : TAG_IGNORE, (ULONG)new.width ,
  933.                                                             (old.height != new.height) ? GA_Height           : TAG_IGNORE, (ULONG)new.height,
  934.                                                                                                                TAG_DONE                     );
  935.                   }
  936.                }
  937.             }
  938.  
  939.             break;
  940.       }
  941.  
  942.       OGT_ReplyMsg( imsg );
  943.    }
  944.  
  945.    return( keeprunning );
  946. }
  947.